package com.heima.search.controller;

import com.heima.common.dtos.AppHttpCodeEnum;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户搜索历史
 */
@RestController
@RequestMapping("/api/v1/history")
public class ApUserSearchController {
    @Autowired
    private ApUserSearchService apUserSearchService;
    /**
     * 加载用户搜索记录
     */
    @PostMapping("/load")
    public ResponseResult load(){
        return apUserSearchService.load();
    }

    /**
     * 删除用户搜素记录
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody HistorySearchDto dto){
        apUserSearchService.del(dto.getId());
        return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }
}
